# coding=utf-8
import arcpy
import json
import F
arcpy.env.overwriteOutput = True
spatial_ref = arcpy.SpatialReference(4326)
with open(r'D:\秋声科技\JSON\高德数据\ya_village_name.json'.decode('utf-8'), 'rb') as file:
    content = file.read().decode('utf-8')
data = json.loads(content)
dataCount = len(data['districts'])
Point_List = []
for i in range(dataCount):
    village = data['districts'][i]['name']
    vX = float(data['districts'][i]['center'].split(',')[0])
    vY = float(data['districts'][i]['center'].split(',')[1])
    vx_trans = F.gcj02_to_wgs84(vX,vY)[0]
    vy_trans = F.gcj02_to_wgs84(vX,vY)[1]
    print vX,vx_trans,vY,vy_trans
    cn = [village, vx_trans, vy_trans]
    Point_List.append(cn)
m_point = arcpy.CreateFeatureclass_management(r'D:\test', 'createdPoint.shp', 'POINT',spatial_reference=spatial_ref)
arcpy.AddField_management(m_point, 'village', 'TEXT')
cs = arcpy.da.InsertCursor(m_point, ['village', 'SHAPE@X', 'SHAPE@Y',])
for Point in Point_List:
    cs.insertRow(Point)
del cs

